package com.xcj.cloud.mapper;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xcj.cloud.entity.House;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.Collection;
import java.util.List;


@Repository
public interface HouseMapper extends BaseMapper<House> {

    //单个查询  ById
    @Select("select * from t_house where hid = #{hid}")
    House getOne(long hid);

    //全查询分页

    @Select(" select * from t_house limit #{page}, #{limit}")
    List<House> page(@Param("page") int page, @Param("limit")int limit);


    //全查询
    @Select("select * from t_house")
    List<House> findHouseAll();

    //计数
    @Select("select count(hid) from t_house")
    int count();


    //单个删除
    @Delete("delete from t_house where hid = #{id}")
    void del(long id);

    //单个插入
    @Insert("INSERT INTO `t_house` (`hid`,`title`, `img`, `images`, `city`, `rent`, `area`, `type`, `mode`, `address`, `explain`, `facilities`, `traffic_info`,`is_del`) " +
            "VALUES (#{hid},#{title}, #{img}, #{images}, #{city}, #{rent}, #{area}, #{type}, #{mode}, #{address}, #{explain}, #{facilities}, #{trafficInfo},#{isDel})")
    void save(House house);

    //批量删除
    void delList(Collection<Long> ids);

    //修改
    void update(House house);
    //全查询
    @Select("select * from t_house")
    List<House> getAll();

}
